<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>042-替换节点.html</title>
</head>
<body>
	<button>替换1</button>
	<button>替换2</button>
	<button>替换3</button>
	<div>div1</div>
	<div>div2</div>
	<div>div3</div>
	<div>div4</div>
</body>
<script src="js/jquery-1.12.4.js"></script>
<script>
	$(function(){
		$('button').eq(0).on('click',function(){
			var $h1 = $('<h1>这是标题</h1>')
			$('div').replaceWith($h1);
		});
		$('button').eq(1).on('click',function(){
			$('div').replaceWith('<h1>这是标题</h1>');
		});
		$('button').eq(2).on('click',function(){
			var $h1 = $('<h1>这是标题</h1>');
			$h1.replaceAll('div');
		});
	})
</script>
</html>